package org.example.springboot.dao;

import org.apache.ibatis.annotations.Mapper;
import org.apache.ibatis.annotations.Select;
import org.example.springboot.common.dao.BaseDao;
import org.example.springboot.entity.FmcBeacon;

import java.util.List;

/**
* 
*
* @author Fz
* @since 1.0.0 2024-08-01
*/
@Mapper
public interface FmcBeaconDao extends BaseDao<FmcBeacon> {
    @Select("SELECT t1.*\n" +
            "FROM fmc_beacon t1\n" +
            "INNER JOIN (\n" +
            "    SELECT did, MAX(ctime) AS max_date\n" +
            "    FROM fmc_beacon\n" +
            "    GROUP BY did\n" +
            ") t2 ON t1.did = t2.did AND t1.ctime = t2.max_date;")
    List<FmcBeacon> selectLatestBeaconsByDid();
	
}